package com.longdaji.decoration.utils;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by Kanade on 2018/5/3 0003.
 */

public class TimeUtil {
    public static String getNowDate() {
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
        return formatter.format(new Date(System.currentTimeMillis()));
    }

    public static String getEasyNowDate() {
        SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
        return formatter.format(new Date(System.currentTimeMillis()));
    }


    public static String getCurrentTime() {
        //我要获取当前的日期
        Date date = new Date();
        //设置要获取到什么样的时间
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        //获取String类型的时间
        String createdate = sdf.format(date);
        return createdate;
    }

    public static boolean isMoreThan7Days(long endDate) {
        SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
        String time1 = formatter.format(new Date(endDate));
        String time2 = getEasyNowDate();
        if (Long.valueOf(time2) - Long.valueOf(time1) > 7000000) {
            return true;
        } else {
            return false;
        }
    }

    public static String getDateToString(long milSecond) {
        if (milSecond == 0)
            return null;
        Date date = new Date(milSecond);
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return format.format(date);
    }

}
